package com.hd.crdao.adapter;

import android.text.TextPaint;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.TextView;

import com.hd.crdao.R;
import com.hd.crdao.base.MyBaseAdapter;
import com.hd.crdao.utils.UIUtils;

import java.util.List;

/**
 *
 *@author Programming
 *@date 2017/7/5 0005
 */

public class ConditionAdapter extends MyBaseAdapter<String> {
    public ConditionAdapter(List<String> dataSets) {
        super(dataSets);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = View.inflate(UIUtils.getContext(), R.layout.condition_item, null);
            //找到控件
            holder.mTextView = (TextView) convertView.findViewById(R.id.conditioon);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.mTextView.setText(mDataSets.get(position));
        TextPaint paint = holder.mTextView.getPaint();
        float measureText = paint.measureText(holder.mTextView.getText().toString());
        AbsListView.LayoutParams params = new AbsListView.LayoutParams((int) measureText, ViewGroup.LayoutParams.WRAP_CONTENT);
       // holder.mTextView.setLayoutParams(params);

        return convertView;
    }


    public class ViewHolder {
        TextView mTextView;
    }
}
